package com.boyuan.aboutcase;

import com.boyuan.huijiaoyu.R;
import com.boyuan.huijiaoyu.R.layout;
import com.boyuan.huijiaoyu.R.menu;
import com.magicsoft.constant.Constant;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

public class CaseChangePriorityActivity extends Activity implements
		OnClickListener {

	private TextView tv_Priority1;
	private TextView tv_Priority2;
	private TextView tv_Priority3;
	private TextView tv_Priority4;
	private TextView tv_Priority5;
	private TextView tv_Priority6;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_case_change_priority);
		initUI();
	}

	private void initUI() {
		tv_Priority1 = (TextView) findViewById(R.id.tv_Priority1);
		tv_Priority1.setOnClickListener(this);
		tv_Priority2 = (TextView) findViewById(R.id.tv_Priority2);
		tv_Priority2.setOnClickListener(this);
		tv_Priority3 = (TextView) findViewById(R.id.tv_Priority3);
		tv_Priority3.setOnClickListener(this);
		tv_Priority4 = (TextView) findViewById(R.id.tv_Priority4);
		tv_Priority4.setOnClickListener(this);
		tv_Priority5 = (TextView) findViewById(R.id.tv_Priority5);
		tv_Priority5.setOnClickListener(this);
		tv_Priority6 = (TextView) findViewById(R.id.tv_Priority6);
		tv_Priority6.setOnClickListener(this);
//		tv_Priority1.setBackgroundColor(Color.parseColor("#cb1a44"));
//		tv_Priority2.setBackgroundColor(Color.parseColor("#ef5b1e"));
//		tv_Priority3.setBackgroundColor(Color.parseColor("#278785"));
//		tv_Priority4.setBackgroundColor(Color.parseColor("#59b2e0"));
//		tv_Priority5.setBackgroundColor(Color.parseColor("#33a6b8"));
//		tv_Priority6.setBackgroundColor(Color.parseColor("#9c90c2"));
		tv_Priority1.setBackgroundDrawable(getResources().getDrawable(R.drawable.priority1));
		tv_Priority2.setBackgroundDrawable(getResources().getDrawable(R.drawable.priority2));
		tv_Priority3.setBackgroundDrawable(getResources().getDrawable(R.drawable.priority3));
		tv_Priority4.setBackgroundDrawable(getResources().getDrawable(R.drawable.priority4));
		tv_Priority5.setBackgroundDrawable(getResources().getDrawable(R.drawable.priority5));
		tv_Priority6.setBackgroundDrawable(getResources().getDrawable(R.drawable.priority6));
	}
	@Override
	public boolean onTouchEvent(MotionEvent event) {
		finish();
		return super.onTouchEvent(event);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.tv_Priority1:
			setP1();
			break;
		case R.id.tv_Priority2:
			setP2();
			break;
		case R.id.tv_Priority3:
			setP3();
			break;
		case R.id.tv_Priority4:
			setP4();
			break;
		case R.id.tv_Priority5:
			setP5();
			break;
		case R.id.tv_Priority6:
			setP6();
			break;

		default:
			break;
		}
	}

	private void setP1() {
		Intent data = new Intent();
		data.putExtra(Constant.CaseChangePriority, "非常紧急");
		setResult(Constant.CaseChangePriority_CODE, data);
		finish();
	}

	private void setP2() {
		Intent data = new Intent();
		data.putExtra(Constant.CaseChangePriority, "紧急");
		setResult(Constant.CaseChangePriority_CODE, data);
		finish();
	}

	private void setP3() {
		Intent data = new Intent();
		data.putExtra(Constant.CaseChangePriority, "重要");
		setResult(Constant.CaseChangePriority_CODE, data);
		finish();
	}

	private void setP4() {
		Intent data = new Intent();
		data.putExtra(Constant.CaseChangePriority, "一般");
		setResult(Constant.CaseChangePriority_CODE, data);
		finish();
	}

	private void setP5() {
		Intent data = new Intent();
		data.putExtra(Constant.CaseChangePriority, "不重要");
		setResult(Constant.CaseChangePriority_CODE, data);
		finish();
	}

	private void setP6() {
		Intent data = new Intent();
		data.putExtra(Constant.CaseChangePriority, "不紧急不重要");
		setResult(Constant.CaseChangePriority_CODE, data);
		finish();
	}

}
